#include <iostream>
using namespace std;

int main()
{
    int C, n;
    bool ugly;
    cin >> C;
    while(C--)
    {
        cin >> n;
        ugly = false;
        while(true)
        {
            if(n % 2 == 0)
            {
                n /= 2;
            }
            else if(n % 3 == 0)
            {
                n /= 3;
            }
            else if(n%5 == 0)
            {
                n /= 5;
            }
            else if(n % 7 == 0)
            {
                n /= 7;
            }
            else if(n == 1)
            {
                ugly = true;
                break;
            }
            else
            {
                break;
            }
        }
        if(ugly)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}